<?php

namespace JLPay\Models\Openmerch\Device;

use JLPay\Models\BaseResponse;

/**
 * 银联码加机响应
 */
class UnionPayCodeAddResponse extends BaseResponse
{
    protected ?string $merchNo = null;
    protected ?string $termNo = null;
    protected ?string $qrcodeUrl = null;

    /**
     * 构造函数
     *
     * @param array|null $responseArray
     */
    public function __construct(?array $responseArray = null)
    {
        parent::__construct($responseArray);
        
        if ($responseArray) {
            $this->merchNo = $responseArray['merch_no'] ?? null;
            $this->termNo = $responseArray['term_no'] ?? null;
            $this->qrcodeUrl = $responseArray['qrcode_url'] ?? null;
        }
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMerchNo(): ?string
    {
        return $this->merchNo;
    }

    /**
     * 获取终端号
     *
     * @return string|null
     */
    public function getTermNo(): ?string
    {
        return $this->termNo;
    }

    /**
     * 获取二维码URL
     *
     * @return string|null
     */
    public function getQrcodeUrl(): ?string
    {
        return $this->qrcodeUrl;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data['merch_no'] = $this->merchNo;
        $data['term_no'] = $this->termNo;
        $data['qrcode_url'] = $this->qrcodeUrl;
        return $data;
    }
} 